# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: 头条.py
"""
'''
参数
url = https://www.toutiao.com/api/pc/list/feed?channel_id=3189398996&min_behot_time=1656680816&refresh_count=2&category=pc_profile_channel&client_extra_params=%7B%22short_video_item%22:%22filter%22%7D&aid=24&app_name=toutiao_web

_signature = window.byted_acrawler.sign(url)

url =  url + _signature   
'''

import time

import urllib3,requests
urllib3.disable_warnings()
def get_sig(url):
    data = {
        "group": "tt-test",
        "action": "toutiao",
        "url": url
    }
    res = requests.post(url="http://127.0.0.1:5620/business-demo/invoke", data=data, verify=False)
    resp = res.json()
    if "?" in url:
        url += "&_signature={}".format(resp['signature'])
    else:
        url += "?_signature={}".format(resp['signature'])
    return url

url = get_sig('https://www.toutiao.com/api/pc/list/feed?channel_id=3189398996&min_behot_time=1656680816&refresh_count=2&category=pc_profile_channel&client_extra_params=%7B%22short_video_item%22:%22filter%22%7D&aid=24&app_name=toutiao_web')
print(url)

